package com.oa.xinxi.biz;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.oa.xinxi.dao.NewsMapper;
import com.oa.xinxi.entity.News;

/**
 * @author xmp
 *新闻模块CRUD
 */
@Service
public class NewsBiz {
	@Resource
	private NewsMapper newsMapper;
	public void save(News news) {
		news.setCreatetime(new Date());
		newsMapper.insert(news);
	}
	public void deleteById(int id) {
		newsMapper.deleteByPrimaryKey(id);
	}
	public void update(News news) {
		news.setUpdatetime(new Date());
		News news2 = newsMapper.selectByPrimaryKey(news.getNewsId());
		news.setCreatetime(news2.getCreatetime());
		news.setCreator(news2.getCreator());
		newsMapper.updateByPrimaryKeySelective(news);
	}
	public News findById(Integer id) {
		return newsMapper.selectByPrimaryKey(id);
	}
	public List<News> findAll() {
		return newsMapper.findAll();
	}
}
